<%-- 
    Document   : index
    Created on : 2016-6-28, 12:09:22
    Author     : 52461
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../link.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style>
           .tab{
                margin-left:20px;
                width:500px;
                /*border-collapse:collapse;*/
                /*border:1px dashed;*/
           }/*
           .tab th, .tab td {
                border:1px dashed;
                padding:0px;
           }*/
           .yb{
               float:left;
           }
            
        </style>
        <title>JSP Page</title>
    </head>
    <body ng-app='hostApp' ng-controller="hostCtrl">
        <div >    
            <div>
                <table>
                    <tr>
                        <td style="width:250px">过滤条件
                            <select style="width:50px">
                                <option>全部</option>
                                <option>已审核</option>
                            </select>
                        </td>
                        <td  style="width:150px">日期<input type="text" style="width:100px"/></td>
                        <td style="width:200px">检验类别<input type="text" style="width:100px"></td>
                        <td><button type="button" id="myButton" class="btn btn-default">刷新</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">审核</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default" ng-click="saveInfo()">保存</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">下一个</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">上一个</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">打印</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">打印预览</button></td>
                        <td><button type="button" id="myButton" class="btn btn-default">历史回顾</button></td>
                    </tr>
                </table>
            </div>
        </div>
       
        <div>
            <table>
                <tr>
                    <td>标本来源: 
                        <select id="bbly" style="width:100px" >
                            <option  value="1" >住院</option>
                            <option  value="2" selected>门诊</option>
                        </select>
                    </td>
                    <td>样本号: <input type="text" ng-model="yb"/></td>
                    <td>条码号: <input type="text"/></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td id="tt">住院号: <input type="text" id="zyh"/></td>
                    <td>病人姓名: <input type="text" value={{info.PATIENTNAME}} /></td>
                    <td>年龄: <input type="text" value={{info.AGE}} /></td>
                    <td>性别: <input type="text" value={{info.SEX}}></td>
                    <td>科室: <input type="text"/></td>
                </tr>
                <tr>
                    <td>床号: <input type="text" value={{info.BED_NO}} /></td>
                    <td>申请医生: <input type="text" value={{info.REQUESTER}} /></td>
                    <td>标本状态: <input type="text"/></td>
                    <td>标本类型: <input type="text"/></td>
                    <td>诊断码: <input type="text"/></td>
                </tr>
                <tr>
                    <td>诊断名称: <input type="text" value={{info.DIAGNOSTIC}} /></td>
                    <td>拼音码: <input type="text"/></td>
                    <td>检查项目: <input type="text" value={{info.EXAMINAIM}} /></td>
                    <td>检验者: <input type="text"/></td>
                    <td>审核者: <input type="text"/></td>
                </tr>
                <tr>
                    <td>化验费: <input type="text"/></td>
                    <td>接收时间: <input type="text" value={{info.REQUESTTIME}}></td>
                    <td>检验时间: <input type="text"/></td>
                    <td>打印时间: <input type="text"/></td>
                </tr>
                <tr>
                    <td>备注:<textarea></textarea></td>
                </tr>
            </table>
            
        </div>
        <div class='yb'>
            <table id='' class="table table-hover table-condensed tab">
                <tr>
                    <th>编号</th>
                    <th>样本号</th>
                    <th>姓名</th>
                    <th>病房</th>
                    <th>样本</th>
                    <th>状态</th>
                    <th>病人ID</th>
                </tr>
                <tr ng-repeat="list in lists" ng-click="getResult(list)">
                    <td>{{$index+1}}</td>
                    <td>{{list.SAMPLENO}}</td>
                    <td>{{list.PATIENTNAME}}</td>
                    <td>{{list.RECEIVER}}</td>
                    <td></td>
                    <td></td>
                    <td>{{list.PATIENTID}}</td>
                </tr>
            </table>
        </div>
        
        <div class='yb'>
            <table class="tab">
                <tr>
                    <th>序号</th>
                    <th>检验项目</th>
                    <th>结果</th>
                    <th></th>
                    <th>参考范围</th>
                    <th>上一次</th>
                    <th>上次样本号</th>
                </tr>
                <tr ng-repeat="re in res">
                    <td>{{$index+1}}</td>
                    <td>{{re.chinesename}}</td>
                    <td>{{re.testresult}}</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
        
        <div id="particles"></div>

    </body>
</html>
<script>
    angular.module("hostApp", [])
            .controller("hostCtrl", function ($scope) {
                $scope.getList=function(){
                    $.post("host/getList",function(data){
                        $scope.lists=data;
                        $scope.$apply();
                     });
                 }
                $scope.getList();
                
                $scope.getResult=function(item){
                    $.post("host/getResult",{ybh:item.SAMPLENO},function(data){
                        $scope.res=data;
                        $scope.yb=item.SAMPLENO;
                        $scope.$apply();
                    })
                }
//                $("#bbly").change(function(){
//                    var ly=$("#bbly").val();
//                    if(ly=='1'){
//                        $("#tt").html('住院号:<input type="text"/>');
//                    }else{
//                        $("#tt").html('门诊号:<input type="text"/>');
//                    }
//                });
                $(function(){ 
                    $(document).keydown(function(event){ 
                        if(event.keyCode==13){ 
                            var zyh=$("#zyh").val();
                            if(zyh!=null||zyh!=""){
                                $("#zyh").click(); 
                            }
                        } 
                    });
                        
                    $("#zyh").click(function(){
                        var zyh=$("#zyh").val();
                        $.post("host/getBrInfo",{brid:zyh},function(data){
                            console.log(data);
                            if(data.SEX=='2'){
                                data.SEX='女';
                            }else{
                                data.SEX=='男';
                            }
                            $scope.info=data;
                            $scope.$apply();
                        });
                    }); 
                }) 
                
               $scope.saveInfo=function(){
                    if($scope.info){
                        $.post("host/saveInfo",{PK:$scope.info.PK,REQUESTER:$scope.info.REQUESTER,REQUESTTIME:$scope.info.REQUESTTIME,SEX:$scope.info.SEX,
                                    STAYHOSPITALMODE:$scope.info.STAYHOSPITALMODE,PATIENTID:$scope.info.PATIENTID,SECTION:$scope.info.SECTION,BED_NO:$scope.info.BED_NO,
                                    PATIENTNAME:$scope.info.PATIENTNAME,BIRTHDAY:$scope.info.BIRTHDAY,AGE:$scope.info.AGE,AGE_UNIT:$scope.info.AGE_UNIT,DIAGNOSTIC:$scope.info.DIAGNOSTIC,
                                    EXAMINAIMCODE:$scope.info.EXAMINAIMCODE,FEE:$scope.info.FEE,HISLB:$scope.info.HISLB,BRXZ:$scope.info.BRXZ,SAMPLENO:$scope.yb
                        },function(data){
                            if(data!="false"){
                                $scope.getList();
                            }else{
                                alert("保存失败！");
                            }
                        });
                    }
                    
               } 
                    
                
    })
</script>
